/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.fasepa.sgpf.entity;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author marcosdj
 */
@Entity
@Table(name = "contrato_servidor")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ContratoServidor.findAll", query = "SELECT c FROM ContratoServidor c"),
    @NamedQuery(name = "ContratoServidor.findById", query = "SELECT c FROM ContratoServidor c WHERE c.id = :id"),
    @NamedQuery(name = "ContratoServidor.findByDataInicio", query = "SELECT c FROM ContratoServidor c WHERE c.dataInicio = :dataInicio"),
    @NamedQuery(name = "ContratoServidor.findByDataFim", query = "SELECT c FROM ContratoServidor c WHERE c.dataFim = :dataFim"),
    @NamedQuery(name = "ContratoServidor.findByMatricula", query = "SELECT c FROM ContratoServidor c WHERE c.matricula = :matricula"),
    @NamedQuery(name = "ContratoServidor.findByVinculo", query = "SELECT c FROM ContratoServidor c WHERE c.vinculo = :vinculo"),
    @NamedQuery(name = "ContratoServidor.findByStatus", query = "SELECT c FROM ContratoServidor c WHERE c.status = :status")})
public class ContratoServidor implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "data_inicio")
    @Temporal(TemporalType.DATE)
    private Date dataInicio;
    @Column(name = "data_fim")
    @Temporal(TemporalType.DATE)
    private Date dataFim;
    @Column(name = "matricula")
    private String matricula;
    @Column(name = "vinculo")
    private String vinculo;
    @Basic(optional = false)
    @Column(name = "numero_doe")
    private String numeroDoe;
    @Column(name = "data_publicacao")
    @Temporal(TemporalType.DATE)
    private Date dataPublicacao;
    @Lob
    @Column(name = "observacao")
    private String observacao;
    @Column(name = "status")
    private String status;
    @JoinColumn(name = "servidor", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Servidor servidor;

    public ContratoServidor() {
    }

    public ContratoServidor(Integer id) {
        this.id = id;
    }

    public ContratoServidor(Integer id, Date dataInicio) {
        this.id = id;
        this.dataInicio = dataInicio;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDataInicio() {
        return dataInicio;
    }

    public String getFormataDataInicio() {
        if (this.getDataInicio() != null) {
            DateFormat dfto = new SimpleDateFormat("dd/MM/yyyy");
            return dfto.format(this.getDataInicio());
        } else {
            return "";
        }
    }

    public void setDataInicio(Date dataInicio) {
        this.dataInicio = dataInicio;
    }

    public Date getDataFim() {
        return dataFim;
    }

    public String getFormataDataFim() {
        if (this.getDataFim() != null) {
            DateFormat dfto = new SimpleDateFormat("dd/MM/yyyy");
            return dfto.format(this.getDataFim());
        } else {
            return "";
        }
    }

    public Date getDataPublicacao() {
        return dataPublicacao;
    }
    
    public String getFormataPublicacao() {
        if (this.getDataPublicacao() != null) {
            DateFormat dfto = new SimpleDateFormat("dd/MM/yyyy");
            return dfto.format(this.getDataPublicacao());
        } else {
            return "";
        }
    }
    
    public void setDataPublicacao(Date dataPublicacao) {
        this.dataPublicacao = dataPublicacao;
    }

    public void setDataFim(Date dataFim) {
        this.dataFim = dataFim;
    }

    public String getMatricula() {
        return matricula;
    }

    public void setMatricula(String matricula) {
        this.matricula = matricula;
    }

    public String getVinculo() {
        return vinculo;
    }

    public void setVinculo(String vinculo) {
        this.vinculo = vinculo;
    }

    public String getNumeroDoe() {
        return numeroDoe;
    }

    public void setNumeroDoe(String numeroDoe) {
        this.numeroDoe = numeroDoe;
    }

    public String getObservacao() {
        return observacao;
    }

    public void setObservacao(String observacao) {
        this.observacao = observacao;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Servidor getServidor() {
        return servidor;
    }

    public void setServidor(Servidor servidor) {
        this.servidor = servidor;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ContratoServidor)) {
            return false;
        }
        ContratoServidor other = (ContratoServidor) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.gov.fasepa.sgpf.entity.ContratoServidor[ id=" + id + " ]";
    }

}
